package com.bra.ui.adapter;

import java.util.ArrayList;
import java.util.List;

import com.bra.R;
import com.bra.bean.HomeMessageBean;
import com.bra.bean.ArticleBean;
import com.bra.view.ImagerLoaderHelper;
import com.nostra13.universalimageloader.core.ImageLoader;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
/**
 * 资讯列表adapter
 * @author lenovo
 *
 */
public class ArticleList_adapter extends BaseAdapter {
	private Context context;
	private List<ArticleBean>ZixunS;
	private ImageLoader imageLoader;
	private ImagerLoaderHelper imageLoaderHelper;

	public ArticleList_adapter(Context context,List<ArticleBean>ZixunS) {
		this.context = context;
		this.ZixunS = ZixunS;
		imageLoader = ImageLoader.getInstance();
		imageLoaderHelper = ImagerLoaderHelper.getInstance();
	}
	/*public void addData(List<ZiZun_infoBean>ZixunS) {
		// TODO Auto-generated method stub
		this.ZixunS.addAll(ZixunS);
	}

	public void setData(List<ZiZun_infoBean>ZixunS) {
		this.ZixunS = ZixunS;
	}*/
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return ZixunS.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return ZixunS.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder=null;
		if (convertView == null) {
			convertView = View.inflate(context,
					R.layout.articlelist_item, null);
			holder = new ViewHolder();
			holder.zixunlist_name = (TextView) convertView
					.findViewById(R.id.zixunlist_name);
			holder.zx_info= (TextView) convertView
					.findViewById(R.id.zx_info);
			holder.zx_image= (ImageView) convertView
					.findViewById(R.id.zx_image);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.zixunlist_name.setText(ZixunS.get(position).getTitle());
		holder.zx_info.setText(ZixunS.get(position).getInfo());
		imageLoader.displayImage(ZixunS.get(position).getImageUrl(), holder.zx_image,imageLoaderHelper.getOptions());				
		return convertView;
	}

	public class ViewHolder {
		public ImageView zx_image;
		private TextView zixunlist_name,zx_info;
	}

}
